package serviceimpl;

import dao.DetailDAO;
import dao.OrderDAO;
import model.Detail;
import model.Order;
import service.OrderService;
import util.OrderPager;
import util.Pager;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by admin on 2016/8/15.
 */

public class OrderServiceImpl implements OrderService{
    private OrderDAO orderDAO;
    private DetailDAO detailDAO;

    public void newOrder(Order order) {
        orderDAO.save(order);
    }

    @Override
    public void newDetail(Detail detail) {
        detailDAO.save(detail);
    }

    @Override
    public void saveOrder(Order order) {
        orderDAO.save(order);
    }

    public Order findById(int id) {
        return orderDAO.findById(id);
    }

    public void delete(Order order) {
        orderDAO.delete(order);
    }

    @Override
    public List findByPage(OrderPager pager) {
        List list = null;
        try {
            list = orderDAO.findByPage(pager);
            return list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    @Override
    public int findMaxPages(OrderPager pager) {
        return orderDAO.getMaxPages(pager);
    }

    public void setOrderDAO(OrderDAO orderDAO) {
        this.orderDAO = orderDAO;
    }

    public void setDetailDAO(DetailDAO detailDAO) {
        this.detailDAO = detailDAO;
    }
}
